<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"    
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
            <p:panel>              
                <p:panelGrid columns="3" >
                    <f:facet name="header">
                        <b>Create New User</b>
                    </f:facet>
                    <p:messages id="msgs"/> 
                    <h:outputLabel value="Name :" for="usName" />
                    <p:inputText id="usName" value="#{userController.selected.usName}" title="Name" 
                                 required="true" requiredMessage="The Name field is required"/>


                    <p:message id="NameMessage" for="usName" display="text"/> 

                    <h:outputLabel value="UserName :" for="usUserName" /> 
                    <p:inputText id="usUserName" value="#{userController.selected.usUserName}" title="UserName" 
                                 required="true" requiredMessage="The UserName field is required">                        
                        <f:validateLength minimum="6" maximum="10" /> 
                    </p:inputText>
                    <p:message id="UserNameMessage" for="usUserName" display="text"/> 

                    <h:outputLabel value="Password :" for="usPassword" />
                    <p:password id="password1" match="password2" feedback="false" value="#{userController.selected.usPassword}" title="Password" 
                                required="true" requiredMessage="The Password field is required">
                        <f:validateLength minimum="6" maximum="10" />
                    </p:password>
                    <p:message id="passwordMessage" for="password1" display="text"/>

                    <h:outputLabel value="Password Confirm :" for="usPassword" />
                    <p:password id="password2" feedback="false" value="#{userController.selected.usPassword}" title="Password" 
                                required="true" requiredMessage="The Password Confirn field is required"/>                     
                    <p:message id="passwordMessage2" for="password2" display="text"/>  

                    <h:outputLabel value="Email" for="usEmail" />
                    <p:inputText id="usEmail" value="#{userController.selected.usEmail}" title="Email" required="true" 
                                 requiredMessage="The Email Confirn field is required">
                        <!-- viết biểu thức phù hợp -->
                        <!--  <f:validateRegex pattern="^[a-zA-Z]" /> -->
                    </p:inputText>
                    <p:message id="usEmailMessage" for="usEmail" display="text"/> 

                    <h:outputLabel value="Address :" for="usAdress" />
                    <p:inputText id="usAdress" value="#{userController.selected.usAdress}" title="Address" />
                    <h:panelGroup/>

                    <h:outputLabel value="Phone" for="usPhone" />
                    <p:inputText id="usPhone" value="#{userController.selected.usPhone}" title="Phone" required="true" 
                                 requiredMessage="The Phone field is required.">
                        <!-- viết biểu thức phù hợp (chỉ được nhập sô -->
                        <!-- <f:validateRegex pattern="^[a-zA-Z]" /> -->
                    </p:inputText>
                    <p:message id="phoneMessage" for="usPhone" display="text"/> 

                    <h:outputLabel value="Company" for="usCompany" />
                    <p:inputText id="usCompany" value="#{userController.selected.usCompany}" title="Company" />
                    <h:panelGroup/>

                    <h:outputLabel value="Status :" for="usStatus" />
                    <p:selectOneRadio id="usStatus" value="#{userController.selected.usStatus}">  
                        <f:selectItem itemLabel="True" itemValue="1" />  
                        <f:selectItem itemLabel="False" itemValue="0" /> 
                    </p:selectOneRadio> 
                    <h:panelGroup/>

                    <f:facet name="footer">
                        <br />
                    </f:facet>

                </p:panelGrid>
                <p:commandButton action="#{userController.create}" value="Save" icon="ui-icon-check" />
                <p:commandButton action="#{userController.prepareList}" value="View All" immediate="true"  icon="ui-icon-script"/>
            </p:panel>
        </h:form>
    </h:body>
</html>

